/**
 * 
 */
package cn.softTank.BpelModelImpl;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.softTank.BpelModel.From;

/**
 * @author Yuzone
 * 
 */
public class FromImpl implements From {

	private String literal;

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.From#getLiteral()
	 */
	@Override
	public String getLiteral() {
		return literal;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.From#setLiteral(java.lang.String)
	 */
	@Override
	public void setLiteral(String value) {
		this.literal = value;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toElement()
	 */
	@Override
	public Element toElement() {
		Element from = DocumentHelper.createElement("from");
		if (literal != null && literal.startsWith("$")) {
			from.addText(literal);
		} else {
			from.addElement("literal").addText(literal);
		}

		return from;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toXml()
	 */
	@Override
	public String toXml() {
		// TODO Auto-generated method stub
		return null;
	}

}
